home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 248 < prev    next >
Encoding:
Text File  |  1996-08-05  |  989 b   |  50 lines

  1. Path: alc.ping.de!chn
  2. From: chn@alc.ping.de (Christian Neise)
  3. Newsgroups: comp.lang.c++
  4. Subject: Copying StdInput to StdOuput
  5. Date: 03 Jan 1996 09:09:05 GMT
  6. Organization: Christian's Linux Private Site
  7. Distribution: world
  8. Message-ID: <CHN.96Jan3100905@alc.alc.ping.de>
  9. NNTP-Posting-Host: alc.ping.de
  10.  
  11.  
  12. Hello!
  13.  
  14. Sorry for this newbie-question:
  15.  
  16. I want to write a filterprogramm under linux, which copies the
  17. modified standardinput to standardouput.
  18.  
  19. I tried:
  20.  
  21. #include <iostream.h>
  22.  
  23. void main(){
  24. char buf[200];
  25. while (!cin.eof())
  26.       { cin >> buf; // or: cin.get(buf, 200, '\n');
  27.         cout << buf;
  28.       }
  29. }
  30.  
  31. I compiled this as test and tried: cat AnyTextfile | test
  32. and I expected to see AnyTextfile on the screen. But it
  33. didn't work. 
  34.  
  35. What's the problem?
  36.  
  37. Thanks in advance for any help!
  38.  
  39. Ciao,
  40. Christian.
  41.  
  42.  
  43.  
  44.     
  45. -- 
  46. Christian Neise 
  47. ---------------
  48. email:  chn@alc.ping.de              phone: +49 - 231 - 751 95 22
  49. pgp-fingerprint: DE B0 C8 EF 42 44 4F 50  2C 2E DC 19 F5 71 65 83
  50.